package com.cw.jeeyt.common;

import java.io.File;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cw.jeeyt.common.utils.FileUtils;
import com.cw.lang.common.utils.PropertiesLoader;

/**
 * 下载模板工具类
 *
* @author chenw
* @version 1.0.0
 */
public class DownLoadTemplateUtil {
    /**
     * 下载模板
     *
     * @param request
     * @param response
     * @param templateName
     */
    public static void downloadTemplate(HttpServletRequest request, HttpServletResponse response, String templateName) {
        //获取模板文件
        PropertiesLoader loader = new PropertiesLoader("classpath:application.properties");
        String templateFilePath = loader.getProperty("excel.template.path");
        String contextPath = DownLoadTemplateUtil.class.getResource("/")
            .getPath();
        File file = new File(contextPath + templateFilePath + templateName);
        FileUtils.downFile(file, request, response);
    }
}
